/**
 * @param {number[]} score
 * @return {string[]}
 */
var findRelativeRanks = function (score) {
  var answer = score.slice(0)
  score.sort(function (a, b) { return b - a })
  for (idx in score) {
    // console.log(idx, answer.indexOf(score[idx]))
    answer[answer.indexOf(score[idx])] = idx
  }
  for (idx in answer) {
    answer[idx] = Number(answer[idx]) + 1
    if (answer[idx] <= 3) {
      if (answer[idx] == 1) answer[idx] = "Gold Medal"
      if (answer[idx] == 2) answer[idx] = "Silver Medal"
      if (answer[idx] == 3) answer[idx] = "Bronze Medal"
    }
  }
  return answer;
}

console.log(findRelativeRanks([5, 4, 3, 2, 1]));

// 输入：score = [5,4,3,2,1]
// 输出：["Gold Medal","Silver Medal","Bronze Medal","4","5"]